<template>
	<view class="unlock">
		<view class="close" @click="$emit('close')">
			<image :src="`${baseImageUrl}/common/close1.png`"></image>
		</view>
		<view class="title">
			<view>解锁空地</view>
		</view>
		<image :src="`${baseImageUrl}/common/unlock2.png`" class="cover"></image>
		<view class="number">
			<text>解锁空地需要消耗</text>
			<text class="value">【{{number}}官银】</text>
		</view>
		<view class="btn_view">
			<view class="cancel" @click="$emit('close')">我再想想</view>
			<view class="confirm" @click="submit">解锁</view>
		</view>
	</view>
</template>

<script>
	import {
		industryUnlock
	} from '@/request/api.js';
	export default {
		props: {
			id: {
				type: [Number, String],
				default: ""
			},
			number: {
				type: [Number, String],
				default: ""
			}
		},
		methods: {
			async submit() {
				await industryUnlock({
					industry_id: this.id
				}, {
					custom: {
						catch: true,
						toast: false
					}
				}).then(() => {
					this.$emit('success')
				}).catch(() => {
					this.$emit('fail')
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	* {
		font-family: SimSun;
	}

	.unlock {
		width: 688rpx;
		height: 606rpx;
		padding: 55rpx 97rpx 70rpx;
		box-sizing: border-box;
		background: url(#{$baseImageUrl}/bg/688_606.png) no-repeat;
		background-size: 100% 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
		position: relative;

		.close {
			width: 122rpx;
			height: 122rpx;
			position: absolute;
			right: 0rpx;
			top: 0rpx;
			transform: translate(50rpx, -50rpx);
			z-index: 2;

			image {
				width: 100%;
				height: 100%;
			}
		}

		// .title {
		// 	width: 256rpx;
		// 	height: 29rpx;
		// }
		.title {
			display: flex;
			justify-content: center;
			align-items: center;

			view {
				width: 256rpx;
				height: 30rpx;
				line-height: 30rpx;
				text-align: center;
				color: #494338;
				font-size: 42rpx;
				font-weight: 400;
				font-family: LiSu;
				background: url(#{$baseImageUrl}/home/title.png) no-repeat;
				background-size: 100% 100%;
			}
		}

		.cover {
			width: 402rpx;
			height: 209rpx;
		}

		.number {
			text {
				color: #494338;
				font-size: 32rpx;
				font-weight: 400;
			}

			.value {
				color: #CA372E;
			}
		}

		.btn_view {
			width: 100%;
			display: flex;
			justify-content: space-between;

			view {
				width: 210rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				color: #FFFFFF;
				font-size: 30rpx;
				font-weight: 400;
			}

			.cancel {
				background: url(#{$baseImageUrl}/common/btn2.png) no-repeat;
				background-size: 100% 100%;
			}

			.confirm {
				background: url(#{$baseImageUrl}/common/btn.png) no-repeat;
				background-size: 100% 100%;
			}
		}
	}
</style>